"use strict";
//vue.config.js
const path = require("path");
function resolve(dir) {
  return path.join(__dirname, dir);
}
const TransformPages = require('uni-read-pages')
const {webpack} = new TransformPages()
module.exports = {
	configureWebpack: {
		plugins: [
			// 在使用了uni-simple-router插件的同时也使用了 uni-read-pages 来读取路由
			new webpack.DefinePlugin({
				ROUTES: webpack.DefinePlugin.runtimeValue(() => {
					const tfPages = new TransformPages({
						includes: ['path', 'name', 'aliasPath']
					});
					return JSON.stringify(tfPages.routes)
				}, true )
			})
		],
		// 路径别名
	  resolve: {
	    alias: {
	      "@/common": resolve("common"),
	      "@/utils": resolve("common/utils"),
				"@/store": resolve("common/store"),
				"@/api": resolve("common/api"),
				"@/style": resolve("common/style"),
	      "@/components": resolve("components"),
				"@/http": resolve("common/http")
	    },
	  },
	  optimization: {
	    minimize: true,
	  }
	}
}